/**
 * 
 */
package fr.fermeManager.library.model.beans;

import java.util.GregorianCalendar;

/**
 * @author Mo
 *
 */
public class Transaction {
	
	private TypeTransaction typeTransaction;
	
	private int id;
	
	private boolean actif = true;
	
	private float montant;
	
	private String libelle;
	
	private String description;
	
	private GregorianCalendar dateCreation = new GregorianCalendar();

	/**
	 * @return the typeTransaction
	 */
	public TypeTransaction getTypeTransaction() {
		return typeTransaction;
	}

	/**
	 * @param typeTransaction the typeTransaction to set
	 */
	public void setTypeTransaction(TypeTransaction typeTransaction) {
		this.typeTransaction = typeTransaction;
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the actif
	 */
	public boolean isActif() {
		return actif;
	}

	/**
	 * @param actif the actif to set
	 */
	public void setActif(boolean actif) {
		this.actif = actif;
	}

	/**
	 * @return the montant
	 */
	public float getMontant() {
		return montant;
	}

	/**
	 * @param montant the montant to set
	 */
	public void setMontant(float montant) {
		this.montant = montant;
	}

	/**
	 * @return the libelle
	 */
	public String getLibelle() {
		return libelle;
	}

	/**
	 * @param libelle the libelle to set
	 */
	public void setLibelle(String libelle) {
		this.libelle = libelle;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Transaction other = (Transaction) obj;
		if (id != other.id)
			return false;
		return true;
	}
	
	@Override
	public Object clone()  {
		
		Transaction newTransaction = new Transaction();
		newTransaction.setActif(actif);
		newTransaction.setDescription(description);
		newTransaction.setId(id);
		newTransaction.setLibelle(libelle);
		newTransaction.setMontant(montant);
		newTransaction.setDateCreation((GregorianCalendar) typeTransaction.getDateCreation().clone());
		newTransaction.setTypeTransaction((TypeTransaction) typeTransaction.clone());
		
		return newTransaction;
	}

	/**
	 * @return the dateCreation
	 */
	public GregorianCalendar getDateCreation() {
		return dateCreation;
	}

	/**
	 * @param dateCreation the dateCreation to set
	 */
	public void setDateCreation(GregorianCalendar dateCreation) {
		this.dateCreation = dateCreation;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
}
